Fix session name too long error when creating from issues#327
Fix session name too long error when creating from issues#327brendanlong merged 2 commits intomainfrom
Conversation
Truncate auto-generated session names from issue titles to 100 chars, add maxLength to the name input field, and use a shared constant for the limit across client and server validation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request implements a 100-character limit for session names across the application, adding truncation logic to the form reducer, enforcing a maximum length on the UI input, and updating server-side validation. The reviewer noted that defining the shared constant within the client-side directory and importing it into the server-side router creates an undesirable dependency. To resolve this architectural anti-pattern, the constant should be moved to a shared directory like 'src/lib'.
src/app/new/form-reducer.ts
Outdated
| import type { Repo } from '@/components/RepoSelector'; | ||
| import type { Issue } from '@/lib/types'; | ||
|
|
||
| export const SESSION_NAME_MAX_LENGTH = 100; |
There was a problem hiding this comment.
Defining SESSION_NAME_MAX_LENGTH in a UI-specific reducer file while also using it in the server-side router (src/server/routers/sessions.ts) creates an undesirable dependency from the server to the client/app directory. This can lead to client-side logic being inadvertently pulled into the server bundle. Consider moving this constant to a shared location like src/lib/constants.ts or src/lib/types.ts to maintain a clean separation of concerns.
src/server/routers/sessions.ts
Outdated
| import { sseEvents } from '../services/events'; | ||
| import { createLogger, toError } from '@/lib/logger'; | ||
| import { env } from '@/lib/env'; | ||
| import { SESSION_NAME_MAX_LENGTH } from '@/app/new/form-reducer'; |
There was a problem hiding this comment.
Importing from the src/app directory into a server-side router is an architectural anti-pattern in Next.js. It violates the separation between UI/client logic and backend logic, and can cause issues with bundle boundaries. Please move SESSION_NAME_MAX_LENGTH to a shared utility or constants file (e.g., in src/lib) and import it from there in both the reducer and this router.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
maxLengthattribute to the session name input field to prevent manual entry beyond the limitSESSION_NAME_MAX_LENGTHconstant shared between client and server validationFixes #324
Test plan
🤖 Generated with Claude Code